package pl.veneo.wigprofit.view.elements {
	import flash.events.MouseEvent;
	import flash.text.TextFormatAlign;
	import flash.text.TextFormat;
	import flash.text.TextFieldAutoSize;
	import pl.veneo.wigprofit.model.Configuration;
	import flash.text.TextField;
	import flash.display.Sprite;

	/**
	 * @author Tomasz Swierszcz, fiodorkrk@gmail.com
	 */
	public class BackButton extends Sprite {
		
		public function BackButton() {
			
			var _info: TextField;
			_info = addChild(new TextField()) as TextField;
			_info.border = true;
			_info.defaultTextFormat = getStyleForIndex();
			_info.borderColor = Configuration.getInstance().lightColor;
			_info.background = true;
			_info.multiline = true;
			_info.backgroundColor = 0xFFFFFF;
			_info.selectable = false;
			_info.mouseEnabled = false;
			_info.autoSize = TextFieldAutoSize.LEFT;
			_info.text = " < POWRÓT DO PEŁNEGO WYKRESU ";
			
			addEventListener(MouseEvent.MOUSE_OVER, onOver);
			addEventListener(MouseEvent.MOUSE_OUT, onOut);
			
			mouseChildren = false;
			mouseEnabled = true;
			buttonMode = true;
			
			onOut();
			
		}

		private function onOut(event : MouseEvent = null) : void {
			
			alpha = 0.3;
			
		}

		private function onOver(event : MouseEvent) : void {
			
			alpha= 1;
			
		}
		
		private function getStyleForIndex() : TextFormat {
			var tf : TextFormat = new TextFormat();
			tf.size = 9;
			tf.align = TextFormatAlign.RIGHT;
			tf.font = "Tahoma";
			tf.color = 0x000000;
			return tf;
		}
		
	}
}
